/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package EDT.form;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

/**
 *
 * @author ali
 */
public class ModifierCrForm extends org.apache.struts.action.ActionForm {
    
    private String key;
    private String[] options;
    private String typeModif;
    private int salle;
    private int interv;
    private String visib;
    private String hdebut;
    private String hfin;
    private int duree;
    private String jour;
    private String timeDecal;
    private String decalage;
    
    
    private String formation;
    private int promo;
    private String periode;
    private int nbrPeriode;
    private int grp;
    

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String[] getOptions() {
        return options;
    }

    public void setOptions(String[] options) {
        this.options = options;
    }

    public String getTypeModif() {
        return typeModif;
    }

    public void setTypeModif(String typeModif) {
        this.typeModif = typeModif;
    }

    public int getSalle() {
        return salle;
    }

    public void setSalle(int salle) {
        this.salle = salle;
    }

    public int getInterv() {
        return interv;
    }

    public void setInterv(int interv) {
        this.interv = interv;
    }

    public String getVisib() {
        return visib;
    }

    public void setVisib(String visib) {
        this.visib = visib;
    }

    public String getHdebut() {
        return hdebut;
    }

    public void setHdebut(String hdebut) {
        this.hdebut = hdebut;
    }

    public String getHfin() {
        return hfin;
    }

    public void setHfin(String hfin) {
        this.hfin = hfin;
    }

   

    public int getDuree() {
        return duree;
    }

    public void setDuree(int duree) {
        this.duree = duree;
    }

    public String getJour() {
        return jour;
    }

    public void setJour(String jour) {
        this.jour = jour;
    }

    public String getTimeDecal() {
        return timeDecal;
    }

    public void setTimeDecal(String timeDecal) {
        this.timeDecal = timeDecal;
    }

    public String getDecalage() {
        return decalage;
    }

    public void setDecalage(String decalage) {
        this.decalage = decalage;
    }

    public int getPromo() {
        return promo;
    }

    public void setPromo(int promo) {
        this.promo = promo;
    }

    public String getPeriode() {
        return periode;
    }

    public void setPeriode(String periode) {
        this.periode = periode;
    }

    public int getNbrPeriode() {
        return nbrPeriode;
    }

    public void setNbrPeriode(int nbrPeriode) {
        this.nbrPeriode = nbrPeriode;
    }

    public int getGrp() {
        return grp;
    }

    public void setGrp(int grp) {
        this.grp = grp;
    }

    public String getFormation() {
        return formation;
    }

    public void setFormation(String formation) {
        this.formation = formation;
    }
    
    

    @Override
    public String toString() {
        String ret="";
        for(String s : options)
        ret += " "+s;
        
        return "ModifierCrForm{" + "key=" + key + ", options=" + ret + ", typeModif=" + typeModif + ", salle=" + salle + ", interv=" + interv + ", visib=" + visib + ", hdebut=" + hdebut + " hfin= "+hfin+", duree=" + duree + ", jour=" + jour + ", timeDecal=" + timeDecal + '}';
    }

    
    /**
     *
     */
    public ModifierCrForm() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * This is the action called from the Struts framework.
     *
     * @param mapping The ActionMapping used to select this instance.
     * @param request The HTTP Request we are processing.
     * @return
     */
    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
        ActionErrors errors = new ActionErrors();
       /*if (getName() == null || getName().length() < 1) {
            errors.add("name", new ActionMessage("error.name.required"));
            // TODO: add 'error.name.required' key to your resources
        }*/
       if (getOptions() == null || getOptions().length  == 0) {
         errors.add("selectCr", new ActionMessage("error.selectCr.required"));
         // TODO: add 'error.name.required' key to your resources
       }
       
       if (typeModif.equals("")) {
         errors.add("selectTypeModifCr", new ActionMessage("error.selectTypeModifCr.required"));
         // TODO: add 'error.name.required' key to your resources
       }
       if (typeModif.equals("salle") && salle == 0) {
         errors.add("selectTypeModifCr", new ActionMessage("error.selectTypeModifCr.required"));
         // TODO: add 'error.name.required' key to your resources
       }
      return errors;
    }
}
